import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useMessageStore = defineStore('message', () => {
  const text = ref('')
  const color = ref('primary')
  const show = ref(false)

  function trigger(msg, type = 'primary') {
    text.value = msg
    color.value = type
    show.value = true
  }

  function clear() {
    text.value = ''
    color.value = 'primary'
    show.value = false
  }

  return { text, color, show, trigger, clear }
})
